<?php
	include("../include/init.php");//将配置文件全部加载进来
	include("../include/check_login.php");//登录

	$insert = new sql_class("article");
	$artcate = new sql_class("article_cate");


	$artcate_list = $artcate->select()->getAll();
	
	

	if($_POST){
		$data = array(
					"article_title"=>$_POST['article_title'],
					"article_author"=>$_POST['article_author'],
					"article_time"=>strtotime($_POST['article_time']),
					"article_desc"=>$_POST['article_desc'],
					"article_content"=>$_POST['article_content'],
					"artcate_id"=>$_POST['artcate_id'],
				);
		//var_dump($data);exit;
		if($_FILES['article_img']['size'] > 0 ){
			$path = DIR."/uploads/";
			$filename = uploads("article_img",1048576,$path);
			$data['article_img'] = "uploads/".$filename;
		}
		$insert_id = $insert->save($data);
		if($insert_id){
			show_msg("添加文章成功","article_list.php");
			exit;
		}else{
			show_msg("添加文章失败","article_add.php");
			exit;
		}
	}
	

	$smarty->assign("artcate_list",$artcate_list);
	$smarty->display("admin/article_add.html");//连接index.html



?>